package com.yswee.mallnavi.activity.base;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yswee.framework.utils.ViewInject;
import com.yswee.mallnavi.Preference;
import com.yswee.mallnavi.R;
import com.yswee.mallnavi.activity.common.AIServiceActivity;
import com.yswee.mallnavi.context.ApiConstant;
import com.yswee.mallnavi.context.ContextConstant;
import com.yswee.mallnavi.entity.common.CompanyEntity;
import com.yswee.mallnavi.model.common.CommonModel;
import com.yswee.mallnavi.view.TopBar;

public abstract class CardActivity extends LoadingActivity {

    @ViewInject
    protected TopBar uvtopbar;
    @ViewInject
    protected View btnaiservice;
    @ViewInject
    protected RelativeLayout rlcontent;
    @ViewInject
    protected TextView tvversion;

    protected CommonModel mCommonModel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_card);
    }

    @Override
    protected void onBindListener() {
        super.onBindListener();
        btnaiservice.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                CompanyEntity company = Preference.getCompany();
                Intent intent = new Intent(CardActivity.this, AIServiceActivity.class);
                intent.putExtra(AIServiceActivity.INTENT_URL, ApiConstant.CHATURL + "?tenant=" + company.id);
                startActivity(intent);
            }
        });
    }

    @Override
    protected void onApplyData() {
        super.onApplyData();
        tvversion.setText("v" + ContextConstant.VERSION);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected void transferContentView(View v) {
        super.transferContentView(v);
        this.rlcontent = v.findViewById(R.id.rlcontent);
        int contentResId = getLayoutResId();
        if(contentResId != 0) {
            View view = LayoutInflater.from(this).inflate(contentResId, null, false);
            this.rlcontent.addView(view, RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        }
    }

    /**
     * 获取布局文件resid
     * @return
     */
    protected int getLayoutResId() {
        return 0;
    }

}
